Class FeatureTracker
Defined in File feature_tracker.h
Class Documentation
-
class FeatureTracker
Visual front end that processes LK optical flow tracking for each feature of each camera.
Public Functions
-
FeatureTracker()
-
map<int, vector<pair<int, Eigen::Matrix<double, 7, 1>>>> trackImage(double _cur_time, const cv::Mat &_img, const cv::Mat &_img1 = cv::Mat(), const cv::Mat &_mask = cv::Mat())
Generate feature properties based on input images.
- Parameters
_cur_time – timestamp of the input image.
_img – Input rectified left image (cv::Mat)
_img1 – Input rectified right image (cv::Mat)
_mask – (Optional) Input mask (to filter out dynamic objects)
- Returns
Special data structure to store features.
-
void setMask()
1) Set small masks around last tracked features, with a predefined radius 2) Set “cubicle” mask for dynamic objects.
-
void readIntrinsicParameter(const vector<string> &calib_file)
Read intrinsic parameters from config file.
- Parameters
calib_file – config file location
-
void showUndistortion(const string &name)
-
vector<cv::Point2f> ptsVelocity(vector<int> &ids, vector<cv::Point2f> &pts, map<int, cv::Point2f> &cur_id_pts, map<int, cv::Point2f> &prev_id_pts)
Calculates the 2D undistorted point velocity.
- Parameters
ids – [in] Input vector of IDs
pts – [in] Input vector of 2D point coordinates
cur_id_pts – [out] std::map of ID and current 2D point coordinates
prev_id_pts – [in] std::map of ID and previous 2D point coordinates
- Returns
Calculated vector of point velocities of each point
-
void showTwoImage(const cv::Mat &img1, const cv::Mat &img2, vector<cv::Point2f> pts1, vector<cv::Point2f> pts2)
-
void drawTrack(const cv::Mat &imLeft, const cv::Mat &imRight, vector<int> &curLeftIds, vector<cv::Point2f> &curLeftPts, vector<cv::Point2f> &curRightPts, map<int, cv::Point2f> &prevLeftPtsMap)
Display visualization of image overlaid by optical flows of tracked features.
- Parameters
imLeft –
imRight –
curLeftIds – Vector of current left feature IDs.
curLeftPts – Vector of current left 2D feature point coordinates.
curRightPts – Vector of current right 2D feature point coordinates
prevLeftPtsMap – Vector of previous left 2D point coordinates
-
void setPrediction(map<int, Eigen::Vector3d> &predictPts)
Predict 2D points based on the 3D predicted points projection.
- Parameters
predictPts – [in] std::map of predicted 3D points associated with IDs @Note There is no return value, but the predict_pts value is the hidden variable to be modified.
-
void removeOutliers(set<int> &removePtsIds)
Removes the invalid points of vector of “prev_pts”, “ids” and “track_cnt” based on flags.
- Parameters
removePtsIds – the set of flags whether the points are outliers or not.
-
cv::Mat getTrackImage()
Inquire the tracked image from external files.
- Returns
TrackImage after drawTrack() is implemented.
-
bool inBorder(const cv::Point2f &pt)
Judge whether a 2D pixel coordinate cv::Point2f is inside the image.
- Parameters
pt – The pixel to be judged.
- Returns
flag true if it is inside the image; false otherwise.
Public Members
-
int row
-
int col
-
cv::Mat imTrack
-
cv::Mat mask
-
cv::Mat prev_img
-
cv::Mat cur_img
-
cv::Mat dy_mask
-
cv::Mat dilate_mask_inv
-
vector<cv::Point2f> n_pts
-
vector<cv::Point2f> predict_pts
-
vector<cv::Point2f> predict_pts_debug
-
vector<cv::Point2f> prev_pts
-
vector<cv::Point2f> cur_pts
-
vector<cv::Point2f> cur_right_pts
-
vector<cv::Point2f> prev_un_pts
-
vector<cv::Point2f> cur_un_pts
-
vector<cv::Point2f> cur_un_right_pts
-
vector<cv::Point2f> pts_velocity
-
vector<cv::Point2f> right_pts_velocity
-
vector<int> ids
-
vector<int> ids_right
-
vector<int> track_cnt
-
map<int, cv::Point2f> cur_un_pts_map
-
map<int, cv::Point2f> prev_un_pts_map
-
map<int, cv::Point2f> cur_un_right_pts_map
-
map<int, cv::Point2f> prev_un_right_pts_map
-
map<int, cv::Point2f> prevLeftPtsMap
-
vector<camodocal::CameraPtr> m_camera
-
double cur_time
-
double prev_time
-
bool stereo_cam
-
int n_id
-
bool hasPrediction
Public Static Functions
-
static vector<cv::Point2f> undistortedPts(vector<cv::Point2f> &pts, camodocal::CameraPtr cam)
Undistort 2D points.
- Parameters
pts – vector of 2D image points
cam – camera model of camodocal
- Returns
The vector of undistorted points
-
FeatureTracker()